//
//  SEGEquipmentFormListModel.m
//  Uhomebk
//
//  Created by mac on 2017/7/5.
//  Copyright © 2017年 com.segi. All rights reserved.
//

#import "SEGTemplateModel.h"
#pragma mark - ================<控件模板模型>===============
@implementation SEGOtherFormsList
- (instancetype)initWithDictionary:(NSDictionary*)dictionary
{
    self = [super init];
    if (self) {
        _equipmentDtInstId = @"";//巡更
        _spotDetailId = @"";//巡检
//        _isUpLoadFaild = NO;
        _form = [[NSArray alloc] init];
        __id = @"";
        [self setValuesForKeysWithDictionary:dictionary];
        
        self.mDictionary = [[NSMutableDictionary alloc] initWithDictionary:dictionary];

    }
    return self;
}

+ (instancetype)initWithDictionary:(NSDictionary*)dictionary
{
    return [[self alloc] initWithDictionary:dictionary];
}

- (void)setValue:(id)value forUndefinedKey:(NSString*)key
{//注意此方法
}

-(void)setValue:(id)value forKey:(NSString *)key
{
    if ([key isEqualToString:@"id"]) {
        self.spotDetailId = self.equipmentDtInstId =self._id = value;
        return;
    }

    if ([key isEqualToString:@"form"]) {
        
        __block NSMutableArray* _arrM = [NSMutableArray array];
        
        [value enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            if([obj isKindOfClass:[SEGTemplateModel class]]){
                [_arrM addObject:obj];
            }else{
                SEGTemplateModel* model = [SEGTemplateModel initWithDictionary:obj];
                [_arrM addObject:model];
            }
        }];
        
        _form = _arrM;
        return;
    }
    [super setValue:value forKey:key];
}



-(void)set_id:(NSString *)_id
{
    __id = [[SEGUtils ValueToString:_id] copy];
}

-(void)setEquipmentDtInstId:(NSString *)equipmentDtInstId
{
    _equipmentDtInstId = [[SEGUtils ValueToString:equipmentDtInstId] copy];
}

-(void)setSpotDetailId:(NSString *)spotDetailId
{
    _spotDetailId = [[SEGUtils ValueToString:spotDetailId] copy];
}


@end

@implementation SEGTemplateModel

- (instancetype)initWithDictionary:(NSDictionary*)dictionary
{
    self = [super init];
    if (self) {
        _attrInstId = @"";
        _seq = @"";
        _disGroupid = @"";
        _attrCode = @"";
        _widgetType= @"";
        _contentLengthLimit = @"";
        _title = @"";
        _readable = @"";
        _markedWords = @"";
        _expressCode = @"";
        _attrValueType = @"";
        _readable = @"";
        _writable = @"";
        _required = @"";
        _defaultData = @"";
        
         self.mDictionary = [[NSMutableDictionary alloc] initWithDictionary:dictionary];
        [self setValuesForKeysWithDictionary:dictionary];
        

    }
    return self;
}

+ (instancetype)initWithDictionary:(NSDictionary*)dictionary
{
    return [[self alloc] initWithDictionary:dictionary];
}

- (void)setValue:(id)value forUndefinedKey:(NSString*)key
{//注意此方法

}

-(void)setAttrInstId:(NSString *)attrInstId
{
    _attrInstId = [[SEGUtils ValueToString:attrInstId] copy];
}

-(void)setSeq:(NSString *)seq
{
    _seq = [[SEGUtils ValueToString:seq] copy];
}

-(void)setDisGroupid:(NSString *)disGroupid
{
    _disGroupid = [[SEGUtils ValueToString:disGroupid] copy];
}

-(void)setAttrCode:(NSString *)attrCode
{
    _attrCode = [[SEGUtils ValueToString:attrCode] copy];
}

-(void)setWidgetType:(NSString *)widgetType
{
    _widgetType = [[SEGUtils ValueToString:widgetType] copy];
}

-(void)setContentLengthLimit:(NSString *)contentLengthLimit
{
    _contentLengthLimit = [[SEGUtils ValueToString:contentLengthLimit] copy];
}

-(void)setTitle:(NSString *)title
{
    _title = [[SEGUtils ValueToString:title] copy];
}

-(void)setMarkedWords:(NSString *)markedWords
{
    _markedWords = [[SEGUtils ValueToString:markedWords] copy];
}

-(void)setExpressCode:(NSString *)expressCode
{
    _expressCode = [[SEGUtils ValueToString:expressCode] copy];
}

-(void)setAttrValueType:(NSString *)attrValueType
{
    _attrValueType= [[SEGUtils ValueToString:attrValueType] copy];
}

-(void)setReadable:(NSString *)readable
{
    _readable = [[SEGUtils ValueToString:readable] copy];
}

-(void)setWritable:(NSString *)writable
{
    _writable = [[SEGUtils ValueToString:writable] copy];
}

-(void)setRequired:(NSString *)required
{
    _required = [[SEGUtils ValueToString:required] copy];
}

-(void)setAttrValue:(NSString *)attrValue
{
    _attrValue= [[SEGUtils ValueToString:attrValue] copy];
}


@end
